<?php

class FileUploadHandler {

	// Function to upload a file. Returns true is successful, otherwise returns false
	function UploadAvatar($file) {
		if ((($_FILES["file"]["type"] == "image/png") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/gif")) && ($_FILES["file"]["size"] < 50000)) {

			if ($file["error"] > 0) {
				return false;
			} else {
				if (file_exists("UploadedFiles/" . $file["name"])) {
					return false;
				} else {
					move_uploaded_file($file["tmp_name"], "UploadedFiles/" . $file["name"]);
					return true;
				}
			}
		}
		return false;
	}

}
